using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;

namespace ZFrameWork.Util
{
    public static class RegexTool
    {
        public static Match GetValueByRule(string fromContent, string searchRule)
        {
            Regex r = new Regex(searchRule);
            Match m = r.Match(fromContent);

            return m;
        }

        public static string GetValueByRuleQuick(string fromContent, string searchRule,string groupName)
        {
            Regex r = new Regex(searchRule);
            Match m = r.Match(fromContent);

            if (m.Success)
                return m.Groups[groupName].ToString();
            else
                return string.Empty;
        }

        public static MatchCollection GetValueCollectionByRule(string fromContent, string searchRule)
        {
            Regex r = new Regex(searchRule);
            MatchCollection ms = r.Matches(fromContent);

            return ms;
        }

        public static string RemoveHTMLFlag(string content)
        {
            return Regex.Replace(content, "<[^>]*>",string.Empty);
        }

    }
}
